/**
 * 
 */
package game;

import java.util.ArrayList;
import java.util.Random;

/**
 * @author patrick
 * 
 */
public class Level {

    private ArrayList<Wall> walls;
    private ArrayList<Switch> switches;
    private String tooltip;

    private ArrayList<String> finishText;
    private int maxAggretateChanges;
    private int levelNr;
    private Sprite finish;

    private String finishimage = "/images/finish.png";
    private String stringOn = "/images/switchON.png";
    private String stringOff = "/images/switchOFF.png";

    private int width;
    private int height;
    private int playerStartX;
    private int playerStartY;
    
//WARNING: ADD A LEVEL AND CHANGE THIS VALUE!!+++++++++++++++++++++++++
    public static final int  totalNrOfLevels = 20;

    public Level(int levelnr, int width, int height) {
    

	finishText = new ArrayList<String>();
	finishText.add("I'm lonely");
	finishText.add("Catch me!");
	finishText.add("Hey!");
	finishText.add("What's up!");
	finishText.add("I'm here!");
	finishText.add("Hey! Ho!");
	finishText.add("Come here!");
	finishText.add("Save me!");

	walls = new ArrayList<Wall>();
	switches = new ArrayList<Switch>();
	this.width = width;
	this.height = height;

	tooltip = null;

	// calls the method that builds the level
	buildLevel(levelnr);
	this.levelNr = levelnr;

	// resetStartingPosition();
	playerStartX = 10;
	playerStartY = 10;
    }

    /**
     * get the list of walls for this level
     * */
    public ArrayList<Wall> getWalls() {
	return this.walls;
    }

    // public int getPlayerStartX(int levelnr) {
    // switch (levelnr) {
    // case 0:
    // return 0;
    // case 1:
    // return 10;
    // case 2:
    // return 0;
    //
    // }
    // return 0;
    // }
    //
    // public int getPlayerStartY(int levelnr) {
    // switch (levelnr) {
    // case 0:
    // return 0;
    //
    // case 1:
    // return 10;
    // case 2:
    // return 100;
    //
    // }
    // return 0;
    // }

    /**
     * set the list of walls for this level
     * */
    public void setWalls(ArrayList<Wall> p) {
	this.walls = p;
    }

    // /**
    // * sets player's starting position to default:
    // * X = 10
    // * Y = 10
    // * */
    // private void resetStartingPosition(){
    // this.playerStartX = 10;
    // this.playerStartY = 10;
    // }

    /**
     * builds the level depending on nr. Inserts walls in list
     * */
    private void buildLevel(int levelnr) {

	int wallThickness = height / 30;

	switch (levelnr) {

	case 0:
	    maxAggretateChanges = 0;

	    walls.add(new Wall(0, 410.0, 800.0, 10.0));
	    // finish = new Sprite(460,360.0,55.0,50.0));
	    this.finish = new Sprite(finishimage, 460, 360);
	    tooltip = "move with arrowkeys to exit ... press R if need to restart";
	    break;

	case 1:
	    maxAggretateChanges = 3;

	    walls.add(new Wall(0, 370.0, 400.0, 10.0));
	    walls.add(new Grid(400, 370.0, 90.0, 10.0));
	    walls.add(new Wall(490, 370.0, 315.0, 10.0));
	    walls.add(new Wall(230, 270.0, 75.0, 75.0));
	    walls.add(new Wall(270, 0.0, 5.0, 270.0));
	    walls.add(new Wall(380, 230.0, 85.0, 75.0));
	    walls.add(new Wall(430, 0.0, 5.0, 230.0));
	    finish = new Sprite(finishimage, 650, 325);
	    tooltip = "you can't pass cyan fields when liquid";
	    break;

	case 2:
	    this.maxAggretateChanges = 1;
	    walls.add(new Wall(0, 100, 200, 10));
	    this.finish = new Sprite(finishimage, 150, 200);
	    tooltip = "sometimes, all you have to do is jump.";
	    break;

	case 3:
	    maxAggretateChanges = 3;
	    walls.add(new Wall(90, 270.0, 285.0, 10.0));
	    walls.add(new Wall(370, 0.0, 5.0, 270.0));
	    walls.add(new Wall(0, 460.0, 235.0, 10.0));
	    walls.add(new Wall(490, 380.0, 310.0, 10.0));
	    walls.add(new Wall(0, 270.0, 90.0, 10.0));
	    tooltip = "jump (as cube) on a switch to use it.";
	    this.finish = new Sprite(finishimage, 50, 400);

	    switches.add(new Switch(stringOff, stringOn, 300, 150));
	    break;

	case 4:
	    maxAggretateChanges = 10;

	    walls.add(new Wall(0, 100.0, 200.0, 10.0));
	    walls.add(new Grid(200, 100.0, 50.0, 10.0));
	    walls.add(new Wall(250, 100.0, 285.0, 10.0));
	    walls.add(new Wall(160, 180.0, 125.0, 10.0));
	    walls.add(new Wall(150, 110.0, 10.0, 80.0));
	    walls.add(new Wall(370, 110.0, 10.0, 240.0));
	    walls.add(new Wall(250, 270.0, 120.0, 10.0));
	    walls.add(new Wall(140, 350.0, 240.0, 10.0));
	    walls.add(new Wall(450, 180.0, 265.0, 10.0));
	    walls.add(new Wall(630, 0.0, 10.0, 120.0));
	    walls.add(new Wall(380, 260.0, 215.0, 10.0));
	    walls.add(new Wall(590, 180.0, 10.0, 190.0));
	    walls.add(new Wall(700, 260.0, 105.0, 10.0));
	    walls.add(new Wall(0, 450.0, 240.0, 10.0));
	    walls.add(new Wall(490, 360.0, 100.0, 10.0));
	    walls.add(new Wall(160, 370.0, 200.0, 10.0));
	    walls.add(new Wall(160, 360.0, 10.0, 10.0));
	    walls.add(new Wall(350, 360.0, 10.0, 10.0));
	    walls.add(new Wall(0, 470.0, 240.0, 10.0));
	    walls.add(new Wall(230, 460.0, 10.0, 10.0));
	    walls.add(new Wall(0, 180.0, 65.0, 10.0));
	    walls.add(new Wall(0, 270.0, 160.0, 10.0));
	    walls.add(new Wall(320, 450.0, 230.0, 10.0));
	    walls.add(new Wall(340, 470.0, 190.0, 10.0));
	    walls.add(new Wall(320, 450.0, 10.0, 130.0));
	    walls.add(new Wall(540, 450.0, 10.0, 130.0));
	    walls.add(new Wall(520, 480.0, 10.0, 100.0));
	    walls.add(new Wall(340, 480.0, 10.0, 100.0));
	    walls.add(new Wall(610, 450.0, 190.0, 10.0));
	    walls.add(new Wall(550, 570.0, 250.0, 10.0));
	    walls.add(new Wall(100, 100.0, 100.0, 10.0));
	    walls.add(new Wall(100, 100.0, 100.0, 10.0));
	    walls.add(new Wall(100, 100.0, 100.0, 10.0));
	    walls.add(new Wall(100, 100.0, 100.0, 10.0));
	    walls.add(new Wall(100, 100.0, 100.0, 10.0));
	    walls.add(new Wall(100, 100.0, 100.0, 10.0));
	    switches.add(new Switch(stringOff, stringOn, 20, 150));
	    walls.add(new Wall(550, 450.0, 250, 10.0));
	    this.finish = new Sprite(finishimage, 600, 530);
	    break;

	case 5:
	    walls.add(new Wall(0, 130.0, 295.0, 40.0));
	    walls.add(new Wall(360, 130.0, 440.0, 40.0));
	    walls.add(new Wall(290, 210.0, 75.0, 45.0));
	    walls.add(new Wall(0, 210.0, 235.0, 45.0));
	    walls.add(new Wall(420, 210.0, 380.0, 45.0));
	    walls.add(new Wall(230, 300.0, 65.0, 45.0));
	    walls.add(new Wall(360, 300.0, 65.0, 45.0));
	    walls.add(new Wall(0, 300.0, 165.0, 45.0));
	    walls.add(new Wall(490, 300.0, 310.0, 45.0));
	    walls.add(new Wall(160, 390.0, 75.0, 45.0));
	    walls.add(new Wall(290, 390.0, 75.0, 45.0));
	    walls.add(new Wall(420, 390.0, 75.0, 45.0));
	    walls.add(new Wall(0, 390.0, 100.0, 45.0));
	    walls.add(new Wall(560, 390.0, 245.0, 45.0));
	    walls.add(new Wall(90, 480.0, 75.0, 45.0));
	    walls.add(new Wall(220, 480.0, 75.0, 45.0));
	    walls.add(new Wall(360, 480.0, 70.0, 45.0));
	    walls.add(new Wall(490, 480.0, 75.0, 45.0));
	    walls.add(new Wall(630, 480.0, 175.0, 45.0));
	    walls.add(new Wall(0, 480.0, 30.0, 45.0));
	    walls.add(new Wall(100, 50.0, 700.0, 40.0));
	    walls.add(new Wall(100, 0.0, 50.0, 50.0));
	    walls.add(new Wall(160, 0.0, 640.0, 40.0));
	    walls.add(new Wall(360, 100.0, 440.0, 20.0));
	    walls.add(new Wall(420, 180.0, 380.0, 20.0));
	    walls.add(new Wall(490, 270.0, 310.0, 20.0));
	    walls.add(new Wall(560, 360.0, 240.0, 20.0));
	    walls.add(new Wall(630, 450.0, 170.0, 20.0));
	    walls.add(new Wall(0, 130.0, 295.0, 40.0));
	    walls.add(new Wall(360, 130.0, 440.0, 40.0));
	    walls.add(new Wall(290, 210.0, 75.0, 45.0));
	    walls.add(new Wall(0, 210.0, 235.0, 45.0));
	    walls.add(new Wall(420, 210.0, 380.0, 45.0));
	    walls.add(new Wall(230, 300.0, 65.0, 45.0));
	    walls.add(new Wall(360, 300.0, 65.0, 45.0));
	    walls.add(new Wall(0, 300.0, 165.0, 45.0));
	    walls.add(new Wall(490, 300.0, 310.0, 45.0));
	    walls.add(new Wall(160, 390.0, 75.0, 45.0));
	    walls.add(new Wall(290, 390.0, 75.0, 45.0));
	    walls.add(new Wall(420, 390.0, 75.0, 45.0));
	    walls.add(new Wall(0, 390.0, 100.0, 45.0));
	    walls.add(new Wall(560, 390.0, 245.0, 45.0));
	    walls.add(new Wall(90, 480.0, 75.0, 45.0));
	    walls.add(new Wall(220, 480.0, 75.0, 45.0));
	    walls.add(new Wall(360, 480.0, 70.0, 45.0));
	    walls.add(new Wall(490, 480.0, 75.0, 45.0));
	    walls.add(new Wall(630, 480.0, 175.0, 45.0));
	    walls.add(new Wall(0, 480.0, 30.0, 45.0));
	    walls.add(new Wall(100, 50.0, 700.0, 40.0));
	    walls.add(new Wall(100, 0.0, 50.0, 50.0));
	    walls.add(new Wall(160, 0.0, 640.0, 40.0));
	    walls.add(new Wall(360, 100.0, 440.0, 20.0));
	    walls.add(new Wall(420, 180.0, 380.0, 20.0));
	    walls.add(new Wall(490, 270.0, 310.0, 20.0));
	    walls.add(new Wall(560, 360.0, 240.0, 20.0));
	    walls.add(new Wall(630, 450.0, 170.0, 20.0));

	    // 2.zeile
	    switches.add(new Switch(stringOff, stringOn, 250, 200));
	    switches.add(new Switch(stringOff, stringOn, 370, 200));

	    // 3.zeile
	    switches.add(new Switch(stringOff, stringOn, 170, 300));
	    // switches.add(new Switch(stringOff, stringOn, 300, 300));
	    switches.add(new Switch(stringOff, stringOn, 420, 300));

	    // 4.zeile
	    switches.add(new Switch(stringOff, stringOn, 100, 400));
	    switches.add(new Switch(stringOff, stringOn, 250, 400));
	    switches.add(new Switch(stringOff, stringOn, 370, 400));
	    switches.add(new Switch(stringOff, stringOn, 490, 400));

	    // 5.zeile
	    /*
	     * switches.add(new Switch(stringOff, stringOn, 40, 500));
	     * switches.add(new Switch(stringOff, stringOn, 170, 500));
	     * switches.add(new Switch(stringOff, stringOn, 300, 500));
	     * switches.add(new Switch(stringOff, stringOn, 420, 500));
	     * switches.add(new Switch(stringOff, stringOn, 550, 500));
	     */
	    this.finish = new Sprite(finishimage, 310, 530);
	    break;

	case 6:
	    walls.add(new Wall(0, 130.0, 645.0, 25.0));
	    walls.add(new Wall(250, 0.0, 100.0, 40.0));
	    walls.add(new Wall(200, 60.0, 150.0, 70.0));
	    walls.add(new Wall(590, 220.0, 210.0, 25.0));
	    walls.add(new Wall(500, 310.0, 30.0, 200.0));
	    walls.add(new Wall(110, 480.0, 575.0, 30.0));
	    walls.add(new Wall(200, 150.0, 30.0, 335.0));
	    walls.add(new Wall(320, 150.0, 30.0, 245.0));
	    walls.add(new Wall(770, -10.0, 10.0, 10.0));
	    walls.add(new Wall(0, 570.0, 800.0, 10.0));
	    walls.add(new Wall(680, 480.0, 120.0, 10.0));
	    this.maxAggretateChanges = 6;
	    switches.add(new Switch(stringOff, stringOn, 290, 230));
	    this.finish = new Sprite(finishimage, 140, 230);
	    // switches.add(new Switch(stringOff, stringOn, 60, 80));

	    break;

	case 66:
	    this.maxAggretateChanges = 9;

	    walls.add(new Wall(100, 100, 100, 10));
	    walls.add(new Wall(50, 140, 25, 25));
	    walls.add(new Wall(80, 140, 25, 25));
	    walls.add(new Wall(20, 140, 25, 25));
	    walls.add(new Wall(110, 170, 25, 25));
	    walls.add(new Wall(110, 200, 25, 25));
	    walls.add(new Wall(80, 170, 25, 25));
	    walls.add(new Wall(0, 280, 195, 15));
	    walls.add(new Wall(180, 390, 100, 135));
	    walls.add(new Wall(80, 390, 100, 10));
	    walls.add(new Wall(320, 440, 100, 10));
	    walls.add(new Wall(0, 570.0, 340.0, 10.0));
	    walls.add(new Wall(490, 90.0, 310.0, 10.0));
	    walls.add(new Wall(100, 100.0, 100.0, 10.0));
	    this.finish = new Sprite(finishimage, 0, 700);
	    break;
	case 7:
	    walls.add(new Wall(260, 60.0, 30.0, 30.0));
	    walls.add(new Wall(290, 60.0, 30.0, 30.0));
	    walls.add(new Wall(230, 90.0, 120.0, 30.0));
	    walls.add(new Wall(200, 120.0, 180.0, 30.0));
	    walls.add(new Wall(170, 150.0, 60.0, 30.0));
	    walls.add(new Wall(260, 150.0, 60.0, 30.0));
	    walls.add(new Wall(350, 150.0, 60.0, 30.0));
	    walls.add(new Wall(170, 180.0, 240.0, 30.0));
	    walls.add(new Wall(230, 210.0, 30.0, 30.0));
	    walls.add(new Wall(320, 210.0, 30.0, 30.0));
	    walls.add(new Wall(260, 240.0, 60.0, 30.0));
	    walls.add(new Wall(200, 240.0, 30.0, 30.0));
	    walls.add(new Wall(350, 240.0, 30.0, 30.0));
	    walls.add(new Wall(230, 270.0, 30.0, 30.0));
	    walls.add(new Wall(170, 270.0, 30.0, 30.0));
	    walls.add(new Wall(320, 270.0, 30.0, 30.0));
	    walls.add(new Wall(380, 270.0, 30.0, 30.0));
	    walls.add(new Wall(0, 150.0, 170.0, 10.0));
	    walls.add(new Wall(410, 150.0, 310.0, 10.0));
	    walls.add(new Wall(0, 290.0, 170.0, 10.0));
	    walls.add(new Wall(410, 170.0, 275.0, 10.0));
	    walls.add(new Wall(0, 170.0, 170.0, 10.0));
	    walls.add(new Wall(0, 190.0, 170.0, 10.0));
	    walls.add(new Wall(410, 190.0, 235.0, 10.0));
	    walls.add(new Wall(410, 290.0, 60.0, 10.0));
	    walls.add(new Wall(0, 310.0, 85.0, 10.0));
	    walls.add(new Wall(550, 290.0, 250.0, 10.0));

	    walls.add(new Wall(130, 310.0, 675.0, 10.0));
	    walls.add(new Wall(50, 330.0, 320.0, 10.0));
	    walls.add(new Wall(0, 330.0, 10.0, 10.0));
	    walls.add(new Wall(50, 350.0, 280.0, 10.0));
	    walls.add(new Wall(50, 370.0, 240.0, 10.0));
	    walls.add(new Wall(80, 390.0, 170.0, 10.0));
	    walls.add(new Wall(120, 410.0, 95.0, 10.0));
	    walls.add(new Wall(70, 130.0, 130.0, 10.0));
	    walls.add(new Wall(380, 130.0, 305.0, 10.0));
	    walls.add(new Wall(420, 330.0, 330.0, 10.0));
	    walls.add(new Wall(380, 350.0, 215.0, 10.0));
	    walls.add(new Wall(450, 370.0, 100.0, 10.0));
	    walls.add(new Wall(320, 370.0, 100.0, 10.0));
	    walls.add(new Wall(290, 390.0, 220.0, 10.0));
	    walls.add(new Wall(10, 470.0, 690.0, 10.0));
	    walls.add(new Wall(500, 320.0, 10.0, 10.0));

	    walls.add(new Wall(540, 340.0, 10.0, 10.0));
	    walls.add(new Wall(250, 410.0, 65.0, 10.0));
	    walls.add(new Wall(390, 410.0, 100.0, 10.0));
	    walls.add(new Wall(0, 570.0, 800.0, 10.0));
	    walls.add(new Wall(600, 270.0, 200.0, 10.0));
	    walls.add(new Wall(0, 210.0, 130.0, 10.0));
	    walls.add(new Wall(0, 230.0, 85.0, 10.0));
	    switches.add(new Switch(stringOff, stringOn, 290, 430));
	    walls.add(new Wall(430, 420.0, 10.0, 50.0));

	    this.finish = new Sprite(finishimage, 140, 530);

	    this.setMaxAggretateChanges(2);
	    break;

	case 8:
	    walls.add(new Wall(200, 0.0, 140.0, 10.0));
	    walls.add(new Wall(190, 10.0, 10.0, 10.0));
	    walls.add(new Wall(340, 10.0, 10.0, 10.0));
	    walls.add(new Wall(180, 20.0, 10.0, 70.0));
	    walls.add(new Wall(350, 20.0, 10.0, 70.0));
	    walls.add(new Wall(200, 100.0, 25.0, 10.0));
	    walls.add(new Wall(190, 90.0, 10.0, 10.0));
	    walls.add(new Wall(340, 90.0, 10.0, 10.0));
	    walls.add(new Wall(220, 100.0, 10.0, 40.0));
	    walls.add(new Wall(230, 130.0, 10.0, 10.0));
	    walls.add(new Wall(250, 110.0, 10.0, 10.0));
	    walls.add(new Wall(260, 100.0, 80.0, 10.0));
	    walls.add(new Wall(240, 120.0, 10.0, 10.0));
	    walls.add(new Wall(0, 170.0, 505.0, 10.0));
	    walls.add(new Wall(440, 110.0, 300.0, 10.0));
	    walls.add(new Wall(580, 120.0, 10.0, 60.0));
	    walls.add(new Wall(380, 230.0, 340.0, 10.0));
	    walls.add(new Wall(650, 170.0, 155.0, 10.0));
	    walls.add(new Wall(230, 290.0, 295.0, 10.0));
	    walls.add(new Wall(290, 330.0, 10.0, 10.0));
	    walls.add(new Wall(280, 340.0, 10.0, 10.0));
	    walls.add(new Wall(270, 350.0, 10.0, 40.0));
	    walls.add(new Wall(300, 350.0, 10.0, 10.0));
	    walls.add(new Wall(340, 350.0, 10.0, 10.0));
	    walls.add(new Wall(300, 320.0, 50.0, 10.0));
	    walls.add(new Wall(350, 330.0, 10.0, 10.0));
	    walls.add(new Wall(360, 340.0, 10.0, 10.0));
	    walls.add(new Wall(280, 390.0, 10.0, 10.0));
	    walls.add(new Wall(290, 400.0, 10.0, 10.0));
	    walls.add(new Wall(300, 410.0, 50.0, 10.0));
	    walls.add(new Wall(370, 350.0, 10.0, 40.0));
	    walls.add(new Wall(360, 390.0, 10.0, 10.0));
	    walls.add(new Wall(350, 400.0, 10.0, 10.0));
	    walls.add(new Wall(310, 390.0, 30.0, 10.0));
	    walls.add(new Wall(300, 380.0, 10.0, 10.0));
	    walls.add(new Wall(340, 380.0, 10.0, 10.0));
	    walls.add(new Wall(80, 290.0, 100.0, 10.0));
	    walls.add(new Wall(300, 520.0, 70.0, 10.0));
	    walls.add(new Wall(380, 510.0, 10.0, 70.0));
	    walls.add(new Wall(580, 260.0, 10.0, 80.0));
	    walls.add(new Wall(160, 230.0, 100.0, 10.0));
	    walls.add(new Wall(0, 370.0, 100.0, 10.0));
	    walls.add(new Wall(150, 300.0, 10.0, 110.0));
	    walls.add(new Wall(160, 370.0, 110.0, 10.0));
	    walls.add(new Wall(380, 370.0, 100.0, 10.0));
	    walls.add(new Wall(510, 440.0, 180.0, 10.0));
	    walls.add(new Wall(380, 240.0, 10.0, 50.0));
	    walls.add(new Wall(250, 240.0, 10.0, 50.0));
	    walls.add(new Wall(420, 470.0, 10.0, 120.0));
	    walls.add(new Wall(400, 480.0, 10.0, 100.0));
	    walls.add(new Wall(240, 470.0, 10.0, 110.0));
	    walls.add(new Wall(260, 480.0, 140.0, 10.0));
	    walls.add(new Wall(260, 490.0, 10.0, 90.0));
	    walls.add(new Wall(280, 500.0, 10.0, 95.0));
	    walls.add(new Wall(290, 500.0, 100.0, 10.0));
	    walls.add(new Wall(300, 520.0, 10.0, 60.0));
	    walls.add(new Wall(320, 540.0, 10.0, 45.0));
	    walls.add(new Wall(320, 540.0, 30.0, 10.0));
	    walls.add(new Wall(340, 550.0, 10.0, 30.0));
	    walls.add(new Wall(360, 520.0, 10.0, 60.0));
	    walls.add(new Wall(590, 260.0, 20.0, 10.0));
	    walls.add(new Wall(240, 460.0, 190.0, 10.0));
	    walls.add(new Wall(60, 460.0, 100.0, 10.0));
	    walls.add(new Wall(600, 260.0, 10.0, 80.0));
	    walls.add(new Wall(600, 330.0, 115.0, 10.0));
	    walls.add(new Wall(580, 210.0, 10.0, 25.0));
	    walls.add(new Wall(710, 230.0, 10.0, 110.0));

	    switches.add(new Switch(stringOff, stringOn, 770, 120));
	    this.finish = new Sprite(finishimage, 650, 530);
	    this.maxAggretateChanges = 3;

	    break;

	case 9:
	    walls.add(new Wall(0,70.0,235.0,10.0));
	    walls.add(new Wall(320,0.0,10.0,160.0));
	    walls.add(new Wall(230,150.0,185.0,10.0));
	    walls.add(new Wall(0,150.0,145.0,10.0));
	    walls.add(new Wall(100,230.0,100.0,10.0));
	    walls.add(new Wall(90,230.0,10.0,190.0));
	    walls.add(new Wall(200,300.0,100.0,10.0));
	    walls.add(new Wall(190,300.0,10.0,205.0));
	    walls.add(new Wall(0,420.0,100.0,10.0));
	    walls.add(new Wall(200,410.0,180.0,10.0));
	    walls.add(new Wall(300,230.0,10.0,80.0));
	    walls.add(new Wall(410,70.0,235.0,10.0));
	    walls.add(new Wall(400,230.0,10.0,110.0));
	    walls.add(new Wall(360,340.0,135.0,10.0));
	    walls.add(new Wall(490,80.0,10.0,160.0));
	    walls.add(new Wall(270,490.0,240.0,10.0));
	    walls.add(new Wall(500,150.0,215.0,10.0));
	    walls.add(new Wall(590,340.0,210.0,10.0));
	    walls.add(new Wall(0,570.0,510.0,10.0));
	    walls.add(new Wall(590,160.0,10.0,110.0));
	    walls.add(new Wall(400,230.0,100.0,10.0));
	    walls.add(new Wall(100,350.0,100.0,10.0));
	    walls.add(new Wall(660,220.0,140.0,10.0));
	    walls.add(new Wall(550,270.0,90.0,10.0));
	    walls.add(new Wall(560,410.0,165.0,10.0));
	    walls.add(new Wall(720,350.0,10.0,70.0));
	    walls.add(new Wall(500,440.0,10.0,130.0));
	    walls.add(new Wall(100,500.0,100.0,10.0));
	    walls.add(new Wall(70,80.0,10.0,20.0));
	    walls.add(new Wall(70,260.0,20.0,10.0));
	    walls.add(new Grid(310,260.0,90.0,10.0));
	    this.finish = new Sprite(finishimage, 700, 530);
	    this.maxAggretateChanges = 3;
	    break;
	case 10:
	    walls.add(new Wall(0,170.0,100.0,10.0));
	    walls.add(new Wall(100,240.0,190.0,10.0));
	    walls.add(new Wall(0,310.0,100.0,10.0));
	    walls.add(new Wall(100,390.0,190.0,10.0));
	    walls.add(new Wall(0,470.0,100.0,10.0));
	    walls.add(new Wall(0,570.0,395.0,10.0));
	    walls.add(new Wall(190,0.0,10.0,480.0));
	    walls.add(new Wall(290,170.0,100.0,10.0));
	    walls.add(new Wall(600,180.0,100.0,10.0));
	    walls.add(new Wall(390,100.0,10.0,480.0));
	    walls.add(new Wall(100,100.0,190.0,10.0));
	    walls.add(new Wall(390,100.0,205.0,10.0));
	    walls.add(new Wall(290,310.0,100.0,10.0));
	    walls.add(new Wall(290,470.0,100.0,10.0));
	    walls.add(new Wall(700,100.0,100.0,10.0));
	    walls.add(new Wall(400,400.0,290.0,10.0));
	    walls.add(new Wall(640,180.0,10.0,115.0));
	    walls.add(new Wall(640,290.0,160.0,10.0));
	    walls.add(new Wall(400,310.0,105.0,10.0));
	    walls.add(new Wall(530,570.0,270.0,10.0));
	    walls.add(new Wall(520,240.0,120.0,10.0));
	    
	    walls.add(new Grid(100,170.0,90.0,10.0));
	    walls.add(new Grid(100,310.0,90.0,10.0));
	    walls.add(new Grid(400,570.0,130.0,10.0));
	    walls.add(new Grid(0,240.0,100.0,10.0));
	    walls.add(new Grid(0,390.0,100.0,10.0));
	    walls.add(new Grid(390,240.0,130.0,10.0));
	    this.finish = new Sprite(finishimage, 420, 530);
	    this.maxAggretateChanges = 6;
	   
	    break;
	
	
	case 11:
	    walls.add(new Wall(90,110.0,10.0,235.0));
	    walls.add(new Wall(0,470.0,265.0,10.0));
	    walls.add(new Wall(190,70.0,10.0,40.0));
	    walls.add(new Wall(90,100.0,190.0,10.0));
	    walls.add(new Wall(90,340.0,100.0,10.0));
	    walls.add(new Wall(190,210.0,265.0,10.0));
	    walls.add(new Wall(330,100.0,125.0,10.0));
	    walls.add(new Wall(450,100.0,10.0,120.0));
	    walls.add(new Wall(260,220.0,10.0,260.0));
	    walls.add(new Wall(460,100.0,230.0,10.0));
	    walls.add(new Wall(550,210.0,145.0,10.0));
	    walls.add(new Grid(690,100.0,110.0,10.0));
	    walls.add(new Grid(690,210.0,110.0,10.0));
	    walls.add(new Wall(680,210.0,10.0,300.0));
	    walls.add(new Wall(690,300.0,55.0,10.0));
	    walls.add(new Wall(340,570.0,460.0,10.0));
	    walls.add(new Wall(450,350.0,230.0,10.0));
	    walls.add(new Wall(270,280.0,185.0,10.0));
	    walls.add(new Wall(270,420.0,185.0,10.0));
	    this.finish = new Sprite(finishimage, 300, 230);
	    this.maxAggretateChanges = 9;break;
	 
	case 12:
	   
	    walls.add(new Wall(100,0.0,10.0,435.0));
	    walls.add(new Wall(100,570.0,700.0,10.0));
	    walls.add(new Wall(270,90.0,10.0,480.0));
	    walls.add(new Wall(200,430.0,70.0,10.0));
	    walls.add(new Wall(100,300.0,70.0,10.0));
	    walls.add(new Wall(200,170.0,70.0,10.0));
	    walls.add(new Wall(280,90.0,185.0,10.0));
	    walls.add(new Wall(560,90.0,155.0,10.0));
	    walls.add(new Wall(600,100.0,10.0,400.0));
	    walls.add(new Wall(390,220.0,210.0,10.0));
	    walls.add(new Wall(480,350.0,10.0,220.0));
	    walls.add(new Wall(700,220.0,100.0,10.0));
	    walls.add(new Wall(610,370.0,100.0,10.0));
	    walls.add(new Grid(460,90.0,100.0,10.0));
	    walls.add(new Grid(600,500.0,10.0,70.0));
	    walls.add(new Wall(610,470.0,190.0,10.0));
	    this.finish = new Sprite(finishimage, 650, 520);
	    switches.add(new Switch(stringOff, stringOn, 650, 60));
	    switches.add(new Switch(stringOff, stringOn, 550, 170));
	    
	    this.maxAggretateChanges = 9;break;
	case 13:
	    walls.add(new Wall(0,60.0,405.0,10.0));
	    walls.add(new Wall(210,130.0,390.0,10.0));
	    walls.add(new Wall(100,200.0,200.0,10.0));
	    walls.add(new Wall(500,200.0,210.0,10.0));
	    walls.add(new Wall(400,140.0,10.0,150.0));
	    walls.add(new Wall(200,210.0,10.0,180.0));
	    walls.add(new Wall(600,210.0,10.0,185.0));
	    walls.add(new Wall(60,270.0,90.0,10.0));
	    walls.add(new Wall(260,270.0,90.0,10.0));
	    walls.add(new Wall(470,270.0,80.0,10.0));
	    walls.add(new Wall(670,270.0,75.0,10.0));
	    walls.add(new Wall(250,500.0,305.0,10.0));
	    this.finish = new Sprite(finishimage, 400, 550);
	    this.maxAggretateChanges = 3; 
	   break;
	
	case 14:
	    walls.add(new Wall(140,0.0,10.0,80.0));
	    walls.add(new Wall(140,80.0,525.0,10.0));
	    walls.add(new Wall(290,90.0,10.0,80.0));
	    walls.add(new Wall(290,160.0,295.0,10.0));
	    walls.add(new Wall(410,170.0,10.0,75.0));
	    walls.add(new Wall(0,160.0,100.0,10.0));
	    walls.add(new Wall(260,240.0,70.0,10.0));
	    walls.add(new Wall(100,360.0,100.0,10.0));
	    walls.add(new Wall(230,440.0,100.0,10.0));
	    walls.add(new Wall(50,260.0,100.0,10.0));
	    walls.add(new Wall(70,500.0,100.0,10.0));
	    walls.add(new Wall(370,330.0,100.0,10.0));
	    walls.add(new Wall(650,470.0,100.0,10.0));
	    walls.add(new Wall(550,290.0,100.0,10.0));
	    walls.add(new Wall(460,450.0,100.0,10.0));
	    walls.add(new Wall(350,540.0,100.0,10.0));
	    walls.add(new Wall(670,200.0,100.0,10.0));
	    this.finish = new Sprite(finishimage, 400, 20);
	    this.maxAggretateChanges = 5;   
	    break;
	case 15:
	    walls.add(new Wall(90,140.0,80.0,10.0));
	    walls.add(new Wall(190,230.0,100.0,10.0));
	    walls.add(new Wall(50,310.0,100.0,10.0));
	    walls.add(new Wall(100,390.0,100.0,10.0));
	    walls.add(new Wall(270,310.0,100.0,10.0));
	    walls.add(new Wall(40,510.0,100.0,10.0));
	    walls.add(new Wall(260,480.0,100.0,10.0));
	    walls.add(new Wall(270,140.0,100.0,10.0));
	    walls.add(new Wall(480,370.0,100.0,10.0));
	    walls.add(new Wall(470,100.0,100.0,10.0));
	    walls.add(new Wall(430,210.0,100.0,10.0));
	    walls.add(new Wall(380,440.0,155.0,10.0));
	    walls.add(new Wall(680,100.0,10.0,385.0));
	    walls.add(new Wall(630,100.0,100.0,10.0));
	    walls.add(new Wall(560,480.0,130.0,10.0));
	    this.finish = new Sprite(finishimage, 600, 550);
	    this.maxAggretateChanges = 3;
	    break;
	case 16:
	    walls.add(new Grid(0,100.0,115.0,10.0));
	    walls.add(new Wall(240,100.0,100.0,10.0));
	    walls.add(new Wall(110,0.0,10.0,270.0));
	    walls.add(new Wall(240,110.0,10.0,250.0));
	    walls.add(new Wall(0,360.0,250.0,10.0));
	    walls.add(new Wall(120,220.0,50.0,10.0));
	    walls.add(new Wall(450,100.0,250.0,10.0));
	    walls.add(new Wall(570,110.0,10.0,275.0));
	    walls.add(new Wall(350,230.0,100.0,10.0));
	    walls.add(new Wall(160,450.0,475.0,10.0));
	    walls.add(new Wall(70,570.0,265.0,10.0));
	    walls.add(new Wall(330,530.0,10.0,55.0));
	    walls.add(new Wall(330,530.0,470.0,10.0));
	    walls.add(new Wall(680,340.0,120.0,10.0));
	    walls.add(new Grid(570,0.0,10.0,100.0));
	    walls.add(new Grid(450,230.0,120.0,10.0));
	    walls.add(new Wall(580,230.0,125.0,10.0));
	    this.finish = new Sprite(finishimage, 600, 180);
	    this.maxAggretateChanges = 5;
	    break;
	
	case 17:
	    walls.add(new Wall(70,430.0,100.0,10.0));
	    walls.add(new Wall(170,320.0,100.0,10.0));
	    walls.add(new Wall(330,380.0,100.0,10.0));
	    walls.add(new Wall(440,270.0,100.0,10.0));
	    walls.add(new Wall(190,180.0,100.0,10.0));
	    walls.add(new Wall(350,140.0,100.0,10.0));
	    walls.add(new Wall(40,220.0,100.0,10.0));
	    walls.add(new Wall(550,450.0,100.0,10.0));
	    walls.add(new Wall(600,140.0,100.0,10.0));
	    walls.add(new Wall(690,80.0,115.0,10.0));
	    walls.add(new Wall(580,230.0,125.0,10.0));
	    this.finish = new Sprite(finishimage, 700, 50);
	    this.maxAggretateChanges = 3;
	    break;
	case 18:
	    walls.add(new Wall(100,70.0,100.0,10.0));
	    walls.add(new Wall(200,70.0,10.0,105.0));
	    walls.add(new Wall(110,170.0,100.0,10.0));
	    walls.add(new Wall(210,120.0,140.0,10.0));
	    walls.add(new Wall(0,250.0,110.0,10.0));
	    walls.add(new Wall(200,250.0,155.0,10.0));
	    walls.add(new Wall(200,330.0,155.0,10.0));
	    walls.add(new Wall(350,200.0,10.0,140.0));
	    walls.add(new Wall(350,190.0,195.0,10.0));
	    walls.add(new Wall(0,410.0,360.0,10.0));
	    walls.add(new Wall(350,60.0,200.0,10.0));
	    walls.add(new Wall(540,130.0,10.0,70.0));
	    walls.add(new Wall(550,130.0,155.0,10.0));
	    walls.add(new Wall(540,260.0,260.0,10.0));
	    walls.add(new Wall(450,330.0,180.0,10.0));
	    walls.add(new Wall(100,490.0,530.0,10.0));
	    walls.add(new Wall(530,340.0,10.0,150.0));
	    walls.add(new Wall(100,570.0,100.0,10.0));
	    walls.add(new Wall(310,570.0,100.0,10.0));
	    walls.add(new Wall(530,570.0,100.0,10.0));
	    walls.add(new Wall(630,410.0,170.0,10.0));
	    walls.add(new Wall(100,500.0,10.0,70.0));
	    this.finish = new Sprite(finishimage, 350, 530);
	    this.maxAggretateChanges = 6;
	    break;
	case 19:
	    walls.add(new Wall(0,80.0,100.0,10.0));
	    walls.add(new Wall(100,80.0,10.0,155.0));
	    walls.add(new Wall(110,170.0,100.0,10.0));
	    walls.add(new Wall(210,150.0,10.0,120.0));
	    walls.add(new Wall(210,140.0,165.0,10.0));
	    walls.add(new Wall(220,260.0,175.0,10.0));
	    walls.add(new Wall(390,260.0,10.0,115.0));
	    walls.add(new Wall(300,370.0,100.0,10.0));
	    walls.add(new Wall(100,450.0,400.0,10.0));
	    walls.add(new Wall(100,330.0,10.0,120.0));
	    walls.add(new Wall(100,570.0,105.0,10.0));
	    walls.add(new Wall(250,530.0,100.0,10.0));
	    walls.add(new Wall(380,550.0,100.0,10.0));
	    walls.add(new Wall(490,80.0,10.0,370.0));
	    walls.add(new Wall(500,140.0,125.0,10.0));
	    walls.add(new Wall(620,140.0,10.0,140.0));
	    walls.add(new Wall(580,280.0,100.0,10.0));
	    walls.add(new Wall(670,290.0,10.0,220.0));
	    walls.add(new Wall(500,400.0,80.0,10.0));
	    walls.add(new Wall(400,70.0,100.0,10.0));
	    walls.add(new Wall(550,510.0,130.0,10.0));
	    walls.add(new Grid(680,420.0,120.0,10.0));
	    this.finish = new Sprite(finishimage, 580, 240);
	    this.maxAggretateChanges = 6;
	    break;
	case 20:
	    walls.add(new Wall(220,110.0,305.0,10.0));
	    walls.add(new Wall(120,160.0,100.0,10.0));
	    walls.add(new Wall(210,110.0,10.0,50.0));
	    walls.add(new Wall(120,230.0,100.0,10.0));
	    walls.add(new Wall(210,240.0,10.0,45.0));
	    walls.add(new Wall(210,280.0,320.0,10.0));
	    walls.add(new Wall(290,200.0,250.0,10.0));
	    walls.add(new Wall(620,200.0,10.0,170.0));
	    walls.add(new Wall(210,360.0,410.0,10.0));
	    walls.add(new Wall(110,410.0,100.0,10.0));
	    walls.add(new Wall(210,370.0,10.0,50.0));
	    walls.add(new Wall(0,230.0,120.0,10.0));
	    walls.add(new Wall(0,500.0,230.0,10.0));
	    walls.add(new Wall(190,520.0,100.0,10.0));
	    walls.add(new Wall(130,540.0,100.0,10.0));
	    walls.add(new Wall(180,560.0,445.0,10.0));
	    walls.add(new Wall(290,370.0,10.0,160.0));
	    walls.add(new Wall(380,490.0,420.0,10.0));
	    walls.add(new Wall(410,510.0,10.0,10.0));
	    walls.add(new Wall(410,540.0,10.0,10.0));
	    walls.add(new Wall(380,430.0,335.0,10.0));
	    walls.add(new Wall(690,0.0,10.0,265.0));
	    walls.add(new Wall(620,200.0,80.0,10.0));
	    walls.add(new Wall(720,370.0,85.0,10.0));
	    walls.add(new Wall(700,120.0,100.0,10.0));
	    this.finish = new Sprite(finishimage, 700, 340);
	    this.maxAggretateChanges = 3;
	    break;
	case 21:
	    walls.add(new Wall(0,100.0,170.0,10.0));
	    walls.add(new Wall(120,120.0,100.0,10.0));
	    walls.add(new Wall(210,130.0,10.0,325.0));
	    walls.add(new Wall(120,250.0,100.0,10.0));
	    walls.add(new Wall(110,510.0,175.0,10.0));
	    walls.add(new Wall(250,100.0,240.0,10.0));
	    walls.add(new Wall(220,120.0,40.0,10.0));
	    walls.add(new Wall(240,110.0,20.0,10.0));
	    walls.add(new Wall(560,100.0,240.0,10.0));
	    walls.add(new Wall(480,160.0,100.0,10.0));
	    walls.add(new Wall(300,160.0,100.0,150.0));
	    walls.add(new Wall(400,250.0,205.0,60.0));
	    walls.add(new Wall(210,380.0,100.0,10.0));
	    walls.add(new Wall(700,270.0,100.0,10.0));
	    walls.add(new Wall(420,310.0,100.0,115.0));
	    walls.add(new Wall(280,510.0,100.0,45.0));
	    walls.add(new Wall(110,330.0,100.0,35.0));
	    walls.add(new Wall(350,440.0,170.0,10.0));
	    walls.add(new Wall(680,200.0,125.0,10.0));
	    walls.add(new Wall(610,350.0,100.0,75.0));
	    walls.add(new Wall(420,510.0,100.0,10.0));
	    walls.add(new Wall(610,470.0,100.0,45.0));
	    walls.add(new Wall(710,420.0,100.0,55.0));
	    walls.add(new Wall(0,410.0,110.0,45.0));
	    walls.add(new Wall(110,530.0,160.0,25.0));
	    walls.add(new Wall(40,190.0,100.0,10.0));
	    walls.add(new Wall(560,0.0,240.0,60.0));
	    walls.add(new Wall(320,0.0,100.0,60.0));
	    walls.add(new Wall(490,570.0,150.0,10.0));
	    this.finish = new Sprite(finishimage, 700, 480);
	    this.maxAggretateChanges = 3;
	    break;
	}
    }

    public int getMaxAggretateChanges() {
	return maxAggretateChanges;
    }

    public void setMaxAggretateChanges(int maxAggretateChanges) {
	this.maxAggretateChanges = maxAggretateChanges;
    }

    /**
     * @return the switches
     */
    public ArrayList<Switch> getSwitches() {
	return switches;
    }

    /**
     * @param switches
     *            the switches to set
     */
    public void setSwitches(ArrayList<Switch> switches) {
	this.switches = switches;
    }

    /**
     * performs the action from specified switch
     * 
     * @param plevelnr
     *            number of level
     * @param switchNr
     *            number of switch: implies the action, e.g "open door xy".
     * */
    public void switchAction(int plevelnr, int switchNr) {

	if (levelNr == plevelnr) {

	    switch (levelNr) {

	    case 0:
		// int this case, we remove the last-inserted wall
		if (switchNr == 0 && !switches.get(switchNr).hasBeenSwitched()) {

		    // walls.remove(walls.size()-1);

		    switches.get(switchNr).setHasBeenSwitched(true);

		}

		break;
	    case 1:
		break;
	    case 2:
		break;
	    case 3:
		// int this case, we rotate the last-inserted wall
		if (switchNr == 0 && !switches.get(switchNr).hasBeenSwitched()) {

		    rotateWall(walls.size() - 1, 0);
		    switches.get(switchNr).setHasBeenSwitched(true);
		}

		break;

	    case 4:
		if (!switches.get(switchNr).hasBeenSwitched()) {

		    walls.remove(walls.size() - 1);
		    switches.get(switchNr).setHasBeenSwitched(true);
		}
		break;
	    case 5:

		// spalten
		// 1. zeile: x value 230 360
		// 2. zeile: x value

		// 1. zeile hoehe 210
		// 2. zeile 300
		// 3. zeile 390
		// 4. zeile
		switch (switchNr) {
		case 0:
		    // walls.add(new Wall(360,390.0,60.0,45.0));
		    // mitte
		    walls.add(new Wall(295, 300.0, 65.0, 45.0));
		    // links
		    // walls.add(new Wall(165, 300.0, 65.0, 45.0));
		    break;
		case 1:
		    walls.add(new Wall(295, 300.0, 65.0, 45.0));
		    // walls.add(new Wall(420, 300.0, 70.0, 45.0));

		    break;

		// naechste zeile

		case 2:
		    walls.add(new Wall(230, 390.0, 70.0, 45.0));

		    break;

		case 3:
		    walls.add(new Wall(360, 390.0, 70.0, 45.0));

		    break;
		// naechste zeile
		case 4:
		    walls.add(new Wall(160, 480.0, 70.0, 45.0));

		    break;

		case 5:
		    walls.add(new Wall(290, 480.0, 70.0, 45.0));

		    break;

		case 6:
		    walls.add(new Wall(290, 480.0, 70.0, 45.0));

		    break;

		case 7:
		    walls.add(new Wall(430, 480.0, 70.0, 45.0));

		    break;
		// naechste zeile
		case 8:
		    walls.add(new Wall(0, 0, 70.0, 45.0));

		    break;

		case 9:
		    walls.add(new Wall(0, 0, 70.0, 45.0));

		    break;

		}
		break;
	    case 6:
		switches.get(switchNr).setHasBeenSwitched(true);
		break;
	    case 55:
		switches.get(switchNr).setHasBeenSwitched(true);
		break;

	    case 8:
		switches.get(switchNr).setHasBeenSwitched(true);
		walls.add(new Wall(690, 510.0, 110.0, 10.0));
		break;
	    case 12:
		if (switchNr == 0 && !switches.get(switchNr).hasBeenSwitched()) {

		switches.get(switchNr).setHasBeenSwitched(true);
		walls.add(new Wall(280,350.0,200.0,10.0));
		}
		else
		if (switchNr == 1 && !switches.get(switchNr).hasBeenSwitched()) {
		    switches.get(switchNr).setHasBeenSwitched(true);
			
		    walls.remove(walls.size()-2);
		}
		break;
		
	    }
	    

	}

    }

    public void update() {
	int wallId = walls.size() - 1;
	if (switches.size() > 0) {
	    if (switches.get(0).hasBeenSwitched()
		    && walls.get(wallId).height > 0) {
		// rotateWall(wallId, walls.get(wallId).getAngle()+Math.PI/6);
		walls.get(wallId).height -= 3;
	    }
	}

    }

    private void rotateWall(int wallId, double angle) {
	walls.get(wallId).setAngle(angle);
    }

    /**
     * @return the finish
     */
    public Sprite getFinish() {
	return finish;
    }

    /**
     * @param finish
     *            the finish to set
     */
    public void setFinish(Sprite finish) {
	this.finish = finish;
    }

    /**
     * @return the levelNr
     */
    public int getLevelNr() {
	return levelNr;
    }

    /**
     * @return the tooltips
     */
    public String getTooltips() {
	return tooltip;
    }

    /**
     * @return the playerStartX
     */
    public int getPlayerStartX() {
	return playerStartX;
    }

    public String getFinishText() {
    	Random random = new Random();
    	int index = random.nextInt(finishText.size());
		return this.finishText.get(index);
    }

    /**
     * @return the playerStartY
     */
    public int getPlayerStartY() {
	return playerStartY;
    }

}
